<template>
	<view class="content">
		<view class="header">
			<view class="denglu">欢迎登录</view>
			<input type="text" placeholder="请输入账号" class="zh" v-model="account">
			<input type="password" placeholder="请输入密码" class="mm" v-model="password">
			<view class="flexbetween xiaohui margin_top">
				<view class="flexleft xiaohui" @click="wangjimm">忘记密码</view>
				<view class="flexright">
					<view class="">没有账户？<text class="xiaohuang" @click="liji">立即注册</text></view>
				</view>
			</view>
			<view class="yue flexleft" @click="changeclick">
				<u-icon name="checkmark-circle-fill" v-if="quan" size="19" color="#fe7200"></u-icon>
				<u-icon name="checkmark-circle-fill" v-if="!quan" size="19" color="#999"></u-icon>
				<view class="xiaohui margin_left1"> 阅读并同意<text class="xiaohuang" @click.stop="guanyuwm(1)">《用户协议》</text>和<text class="xiaohuang"
						@click.stop="guanyuwm(2)">《隐私政策》</text></view>
			</view>
		
			<view class="dl" @click="thelogin">登录</view>
			
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				quan: false,
				account: "",
				password: "",
			}
		},
		onLoad() {

		},
		methods: {
			wangjimm(){
				uni.navigateTo({
					url:"/pages/login/wangjimm"
				})
			},
			guanyuwm(type) {
				uni.navigateTo({
					url: '/pages/system/system?type=' + type
				})
			},
			thelogin() {
				let _this = this
				let mobile = _this.account;
				let password = _this.password
				if (mobile == '') {
					httpRequest.toast('请输入手机号');
					return false;
				}
				if (!mobile.match(/^1\d{10}$/)) {
					httpRequest.toast("请输入有效的手机号码");
					return false;
				}
				if (password == "") {
					httpRequest.toast('请输入密码');
					return false;
				}
				if (!_this.quan) {
					httpRequest.toast('请仔细阅读用户协议并勾选');
					return false;
				}
				httpRequest.request('user/login', 'POST', {
					account: mobile,
					password: password
				}).then(resp => {
					if (resp.code == 1) {
						httpRequest.toast(resp.msg);
						let userinfo = resp['data']['userinfo'];
						uni.setStorageSync('token', userinfo['token']);
						uni.setStorageSync('user_id', userinfo['user_id']);
						setTimeout(() => {
							uni.navigateBack(1)
						}, 1000)
					}
					if (resp.code == 0) {
						httpRequest.toast(resp.msg);
					}
				})
			},
			changeclick() {
				this.quan = this.quan ? false : true
			},
			liji() {
				uni.navigateTo({
					url: '/pages/login/register'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #ffffff;
		// min-height: 80vh;
	}

	.header {
		padding: 0rpx 30rpx;
	}

	.denglu {
		padding-top: 208rpx;
		font-size: 40rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
	}

	input:input-placeholder {
		color: #999999;
	}

	.zh {
		margin-top: 86rpx;
		padding-bottom: 28rpx;
		border-bottom: 1rpx solid rgba(153, 153, 153, 0.10);
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
	}

	.mm {
		margin-top: 44rpx;
		border-bottom: 1rpx solid rgba(153, 153, 153, 0.10);
		padding-bottom: 28rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
	}

	.wangji {
		margin-top: 28rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.yue {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
		margin-top: 71rpx;
		margin-left: 10rpx;
		margin-right: 8rpx;
	}

	.dui {
		width: 26rpx;
		height: 26rpx;
		margin-right: 7rpx;
	}

	.dui1 {
		width: 23rpx;
		height: 23rpx;
		margin-right: 7rpx;
		border: 1rpx solid #999;
		border-radius: 50%;
	}

	.dl {
		margin-left: 10rpx;
		margin-right: 8rpx;
		margin-top: 29rpx;
		width: 672rpx;
		height: 82rpx;
		background-color: #fe7200;
		font-size: 32rpx;
		border-radius: 41rpx 41rpx 41rpx 41rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 82rpx;
		text-align: center;
	}

	.wx_sq {
		margin-left: 10rpx;
		margin-right: 8rpx;
		margin-top: 37rpx;
		width: 672rpx;
		height: 82rpx;
		background-color: #ffffff;
		border: 1rpx solid #fe7200;
		color: #fe7200;
		border-radius: 41rpx 41rpx 41rpx 41rpx;
		font-size: 32rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		line-height: 82rpx;
		text-align: center;
	}

	.my {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
		text-align: center;
		margin-top: 29rpx;
	}

	.lj {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #fe7200;
		text-align: center;
		margin-top: 29rpx;
	}
</style>